//
//  ZLMainViewController.m
//  ZLExamination
//
//  Created by Zheng on 2017/8/9.
//  Copyright © 2017年 Zheng. All rights reserved.
//

#import "ZLMainViewController.h"
#import "ZLPersonalCenterViewController.h"
#import "ZLTabBarController.h"

static ZLTabBarController *_tabBarVC;
static ZLPersonalCenterViewController *_personalVC;


@interface ZLMainViewController () <PKRevealing>

@property (nonatomic, assign) BOOL isStatusHidden;

@end

@implementation ZLMainViewController

+ (void)initialize {
    _tabBarVC = [[ZLTabBarController alloc] init];
    _personalVC = [[ZLPersonalCenterViewController alloc] init];
}

#pragma mark - 初始化方法
+ (instancetype)getInstance {
    return [super revealControllerWithFrontViewController:_tabBarVC leftViewController:_personalVC];
}

#pragma mark - 视图生命周期
- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];
    self.delegate = self;
    self.animationDuration = kANIMATION_DURATION;
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationAction) name:kShowPersonalCenterControllerNotification object:nil];
    
}

- (void)notificationAction {
    [self showViewController:_personalVC animated:YES completion:^(BOOL finished) {
        
    }];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
//    _isStatusHidden = NO;
    
//    [self setNeedsStatusBarAppearanceUpdate];
}

#pragma mark - 状态栏
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

- (UIStatusBarAnimation )preferredStatusBarUpdateAnimation {
    return UIStatusBarAnimationSlide;
}

//- (BOOL)prefersStatusBarHidden {
//    return _isStatusHidden;
//}

#pragma mark PKRevealing代理方法
- (void)revealController:(PKRevealController *)revealController didChangeToState:(PKRevealControllerState)state{
    
//    _isStatusHidden = (state == PKRevealControllerShowsFrontViewController)? NO: YES;
//    
    [_tabBarVC changeMaskViewHiddenStateWithState:state withFinishBlock:^{
//        [UIView animateWithDuration:kANIMATION_DURATION animations:^{
//            [self setNeedsStatusBarAppearanceUpdate];
//        }];
    }];

}

#pragma mark - 内存警告
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
